

#如果没有赋值，就给这个值
PREFIX ?= ../install 
#PRJNAME = server_main
SPRJNAME = mqttsub
PRJNAME = mqttpub
LIBNAME = sqlitet3
LOGNAME = logger

CFLAGS  += -I ../include -I /home/zkf/install/include#-I 头文件路径 -L 动态库路径
LDFLAGS += -L ../lib -L /home/zkf/install/lib -lmosquitto -lsrc -lsqlite3 -liniparser -lmqtt_config -lcJSON -ldictionary
RUNFLAGS += -p 1884 -n 127.0.0.1
PRUNFLAGS += -s ZKF0001 -t 10

all: 
	gcc  ${PRJNAME}.c -o ${PRJNAME} ${CFLAGS} ${LDFLAGS}
	gcc  ${SPRJNAME}.c -o ${SPRJNAME} ${CFLAGS} ${LDFLAGS}



static_lib:
	gcc -c sqlite3.c
	ar -rcs lib${LIBNAME}.a sqlite3.o

shared_lib:
	gcc -shared -fPIC sqlite3.c -o lib${LIBNAME}.so

LD_export:
	export LD_LIBRARY_PATH=$ LD_LIBRARY_PATH:/home/zkf/zhukaifa/mqtt/lib/:/home/zkf/install/lib
#/home/zkf/install/lib             PATH of libsqlite3 

prun:
	./${PRJNAME} ${RUNFLAGS} ${PRUNFLAGS}
srun:
	./${SPRJNAME} ${RUNFLAGS}



clean:
	rm *.db
	rm ${PRJNAME}
	rm pub sub


#创建include存放头文件，创建lib存放静态库和动态库
install:
	cp lib*.a lib*.so ${PREFIX}/lib
	cp *.h ${PREFIX}/include

